package net.sipvip.client;

import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.DecoratedPopupPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;

public class ImageHoverHandler extends Image {

	DecoratedPopupPanel popup = new DecoratedPopupPanel(true);
	
    final String popstrint;
	public ImageHoverHandler(String popstr) {
		super();
		popstrint = popstr;
		sinkEvents(Event.ONMOUSEOVER);
		sinkEvents(Event.ONMOUSEOUT);
		popup.setAnimationEnabled(true);
	}

	@Override
	public void onBrowserEvent(Event event) {
		switch (DOM.eventGetType(event)) {
		case Event.ONMOUSEOVER:
			popup.setWidget(new HTML(popstrint));
			int left = this.getAbsoluteLeft() - 10;
			int top = this.getAbsoluteTop() +this.getHeight() + 20;
			popup.setWidth("450px");
			popup.setPopupPosition(left, top);
			popup.show();
			break;

		case Event.ONMOUSEOUT:
			popup.removeFromParent();
			break;
					
		default:
			break;
		}
	}

}
